#define DEBUG
#include <cstdio>
#include <cmath>
#define MAXTIME 60000000

using namespace std;

#define MAXN 5000
#define MAXM 5000
class Graph {
public:
  int n, m, ind[MAXN+1], to[MAXM*2+1], prev[MAXM*2+1], next[MAXM*2+1], color[MAXN+1], vers[MAXN+1];

  void addSide(int u, int v) {
    m++;
    to[m] = v;
    next[m] = ind[u];
    ind[u] = prev[next[m]] = m;
  }

  void delSide(int u, int v) {
    for (int i=ind[u]; i; i=next[i]) {
      if (to[i]==v) {
	prev[next[i]] = prev[i];
	if (prev[i]) {
	  next[prev[i]] = next[i];
	} else {
	  ind[u] = next[i];
	}
      }
    }
  }

  bool calc(int o, int ver) {
    if (vers[o]!=ver) {
      color[o] = 1;
      vers[o] = ver;
    }
    bool flag=true;
    for (int i=ind[o]; flag && i; i=next[i]) {
      if (vers[to[i]]!=ver) {
	color[to[i]] = abs(color[o]-2)+1;
	vers[to[i]] = ver;
	flag = flag&&calc(to[i], ver);
      } else if (color[to[i]]==color[o]) {
	return false;
      }
    }
    return flag;
  }
};

void solve1(int n, int m) {
  static int a[MAXM+1], b[MAXM+1];
  static Graph g;
  int p=0;
  for (int i=1; i<=m; i++) {
    int type;
    scanf("%d", &type);
    if (type) {
      p++;
      scanf("%d %d", a+p, b+p);
      a[p]++, b[p]++;
      g.addSide(a[p], b[p]), g.addSide(b[p], a[p]);
    } else {
      int x;
      scanf("%d", &x);
      x++;
      g.delSide(a[x], b[x]), g.delSide(b[x], a[x]);
    }
    bool ans=true;
    for (int j=1; ans && j<=n; j++) {
      if (g.vers[j]!=i) {
	ans = ans&&g.calc(j, i);
      }
    }
    printf(ans ? "YES\n" : "NO\n");
  }
}

#define MAXN 300000
#define MAXM 300000

class Set {
public:
  int fa[MAXN+1], len[MAXN+1];

  void init(int n) {
    for (int i=1; i<=n; i++) {
      fa[i] = i, len[i] = 0;
    }
  }

  int getFa(int o) {
    if (fa[o]!=o) {
      int temp=fa[o];
      fa[o]=getFa(fa[o]);
      len[o] = (len[o]+len[temp])%2;
    }
    return fa[o];
  }

  bool merge(int u, int v) {
    if (getFa(u)==getFa(v)) {
      return !((len[u]+len[v])%2);
    } else {
      len[getFa(u)] = 1;
      fa[getFa(u)] = v;
      return true;
    }
  }
};

void solve2(int n, int m) {
  static Set set;
  set.init(n);
  for (int i=1; i<=m; i++) {
    int type, a, b;
    scanf("%d %d %d", &type, &a, &b);
    printf(set.merge(a, b) ? "YES\n" : "NO\n");
  }
}

int main() {
  freopen("graph.in", "r", stdin);
  freopen("graph.out", "w", stdout);

  int n, m;
  scanf("%d %d", &n, &m);

  if (n*m<=MAXTIME) {
    solve1(n, m);
  } else {
    solve2(n, m);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
